/*****************************************************************************
*
*  PROJECT:     SlipStream
*               (CSingleton Class)
*  LICENSE:     GNU General Public License v3 - http://www.gnu.org/licenses/gpl.html

*  DEVELOPERS:  Philip Farquharson 	<B00137077@studentmail.uws.ac.uk>
*				John Gray 			<B00145524@studentmail.uws.ac.uk>		
*				Zohaib Bhatti		<B00104280@studentmail.uws.ac.uk>
*				Euan Hislop 		<B00138636@studentmail.uws.ac.uk>
*
*			This portion of code is Copyright (C) Scott Bilas, 2000
*							Game Programming Gems
*****************************************************************************/

#ifndef CSINGLETON_H
#define CSINGLETON_H

#include <cassert>
#include "lib.h"

template <typename T> class CSingleton
{
	protected:
		static T* m_pSingleton;

	public:
		CSingleton ( void )
		{
			if ( m_pSingleton )
				return;

			m_pSingleton = static_cast< T* > ( this );
		}

		~CSingleton ( void )
		{

		}

		static T& GetSingleton ( void )
		{
			assert ( m_pSingleton );
			return ( *m_pSingleton );
		}

		static T* GetSingletonPtr ( void )
		{
			return m_pSingleton;
		}
};
#endif